<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Chapter&nbsp;12.&nbsp;日程调度器（Scheduler）</title>
    <link rel="stylesheet" href="css/html.css" type="text/css">
    <meta name="generator" content="DocBook XSL Stylesheets V1.65.1">
    <link rel="home" href="index.html" title="JBoss jBPM 3.1">
    <link rel="up" href="index.html" title="JBoss jBPM 3.1">
    <link rel="previous" href="taskmanagement.html" title="Chapter&nbsp;11.&nbsp;Task management">
    <link rel="next" href="asynchronouscontinuations.html" title="Chapter&nbsp;13.&nbsp;Asynchronous continuations">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
    <table width="100%" summary="Navigation header">
        <tr>
            <th colspan="3" align="center">Chapter&nbsp;12.&nbsp;日程调度器（Scheduler）</th>
        </tr>
        <tr>
            <td width="20%" align="left"><a accesskey="p" href="taskmanagement.html">Prev</a>&nbsp;</td>
            <th width="60%" align="center">&nbsp;</th>
            <td width="20%" align="right">&nbsp;<a accesskey="n" href="asynchronouscontinuations.html">Next</a></td>
        </tr>
    </table>
    <hr>
</div>
<div class="chapter" lang="cn">
    <div class="titlepage">
        <div>
            <div><h2 class="title"><a name="scheduler"></a>Chapter&nbsp;12.&nbsp;日程调度器（Scheduler）</h2></div>
        </div>
        <div></div>
    </div>
    <p>This chapter describes how to work with timers in jBPM.</p>

    <p>Upon events in the process, timers can be created. When a timer
        expires, an action can be executed or a transition can be taken.</p>

    <div class="section" lang="cn">
        <div class="titlepage">
            <div>
                <div><h2 class="title" style="clear: both"><a name="timers"></a>12.1.&nbsp;定时器（Timers）</h2></div>
            </div>
            <div></div>
        </div>
        <p>The easiest way to specify a timer is by adding a timer element
            to the node.</p><pre class="programlisting">&lt;state name='catch crooks'&gt;
  &lt;timer name='reminder' 
         duedate='3 business hours' 
         repeat='10 business minutes'
         transition='time-out-transition' &gt;
    &lt;action class='the-remainder-action-class-name' /&gt;
  &lt;/timer&gt;
&lt;/state&gt;</pre>
        <p>A timer that is specified on a node, is not executed after the node
            is left. Both the transition and the action are optional. When a timer
            is executed, the following events occur in sequence : </p>

        <div class="itemizedlist">
            <ul type="disc">
                <li>an event is fired of type <tt class="literal">timer</tt></li>
                <li>if an action is specified, the action is executed.</li>
                <li>if a transition is specified, a signal will be sent to resume execution
                    over the given transition.
                </li>
            </ul>
        </div>
        <p>Every timer must have a unique name. If no name is specified in the
            <tt class="literal">timer</tt> element, the name of the node is taken as the name
            of the timer.</p>

        <p>The timer action can be any supported action element like e.g.
            <tt class="literal">action</tt> or <tt class="literal">script</tt>.</p>

        <p>Timers are created and cancelled by actions. The 2 action-elements are
            <tt class="literal">create-timer</tt> and <tt class="literal">cancel-timer</tt>. Actually, the
            timer element shown above is just a short notation for a create-timer action
            on <tt class="literal">node-enter</tt> and a cancel-timer action on
            <tt class="literal">node-leave</tt>.</p></div>
    <div class="section" lang="cn">
        <div class="titlepage">
            <div>
                <div><h2 class="title" style="clear: both"><a name="schedulerdeployment"></a>12.2.&nbsp;部署日程调度器</h2></div>
            </div>
            <div></div>
        </div>
        <p>Process executions create and cancel timers. The timers are stored in
            a timer store. A separate timer runner must check the timer store and execute
            the timers when they are due.</p>

        <div class="figure"><a name="scheduler.overview.image"></a>

            <div class="mediaobject" align="center"><img src="images/scheduler.overview.gif" align="middle"
                                                         alt="Scheduler components overview"></div>
            <p class="title"><b>Figure&nbsp;12.1.&nbsp;Scheduler components overview</b></p></div>
        <p>The following class diagram shows the classes that are involved in the
            scheduler deployment. The interfaces <tt class="literal">SchedulerService</tt> and
            <tt class="literal">TimerExecutor</tt> are specified to make the timer execution mechanism
            pluggable.</p>

        <div class="figure"><a name="scheduler.classes.image"></a>

            <div class="mediaobject" align="center"><img src="images/scheduler.classes.gif" align="middle"
                                                         alt="Scheduler classes overview"></div>
            <p class="title"><b>Figure&nbsp;12.2.&nbsp;Scheduler classes overview</b></p></div>
    </div>
</div>
<div class="navfooter">
    <hr>
    <table width="100%" summary="Navigation footer">
        <tr>
            <td width="40%" align="left"><a accesskey="p" href="taskmanagement.html">Prev</a>&nbsp;</td>
            <td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
            <td width="40%" align="right">&nbsp;<a accesskey="n" href="asynchronouscontinuations.html">Next</a></td>
        </tr>
        <tr>
            <td width="40%" align="left" valign="top">Chapter&nbsp;11.&nbsp;Task management&nbsp;</td>
            <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
            <td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;13.&nbsp;Asynchronous continuations</td>
        </tr>
    </table>
</div>
</body>
</html>